/**
 * Created by ZhangYinxian on 2014/11/17.
 */
$(function(){
    $("#menu").children("li").addClass("menu-header");
    $("#menu").children("li").children("a").addClass("menu-link");

    /**
     * 修复bootstrap中navbar中的弹出框位置
     */
    $("#menu li.menu-header").on("click",function(){
        var offsetLeft = this.offsetLeft;
        var dropmenu = $(this).children(".dropdown-menu");
        if(dropmenu!=undefined){
            dropmenu.css("left",this.offsetLeft+"px");
        }
    });

    /*
    修复空div的line-height默认为20px的问题
     */
    $(".height-5").css("line-height","5px");

    fix_png();
});

/* iosslider ie6 bug fiexed*/
function fixed_ie6(args){
    var selectedItem = $(".slideSelectors div.item.selected");
    var index = -1;
    if (selectedItem != undefined) {
        index = selectedItem.attr("data-index");
    }
    //var index = $(".slideSelectors div.selected").getAttribute("data-index");
    var target = $(".sliderContainer .slideContent");
    // console.debug(index);
    if (index != -1) {
        var slides =  $(".slider .slide");
        var currentSlide = null;
        $.each(slides,function(i,element){
            var dIndex = element.getAttribute("data-index");
            if(dIndex==index){
                currentSlide = element;
                $(element).show("slow");
            }else{
                $(element).hide();
            }
        });

    }
}

function fix_png(){
    var pngs = $(".tile-front img");
    if(pngs!=undefined){
        $.each(pngs,function(index,element){
            var path = element.src;
            if(path.lastIndexOf(".png")!=-1){
                element.src = path.replace(".png",".gif");
            }
        });
    }
}